package com.leyou.system.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Date: 2019/11/28
 * Author: L
 * Description: 权限实体类
 */
@Data
@Table(name = "sys_permission")
public class Permission {

    // 菜单id
    @Id
    @KeySql(useGeneratedKeys = true) // 保存对象成功后可以得到新保存数据的id
    private Integer id;

    // 菜单名称
    private String name;

    // 菜单地址
    private String path;

    // 图标
    private String action;

    // 父菜单id
    private Integer parentId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Permission)) return false;

        Permission that = (Permission) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (path != null ? !path.equals(that.path) : that.path != null) return false;
        if (action != null ? !action.equals(that.action) : that.action != null) return false;
        return parentId != null ? parentId.equals(that.parentId) : that.parentId == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (path != null ? path.hashCode() : 0);
        result = 31 * result + (action != null ? action.hashCode() : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
        return result;
    }
}
